﻿/* 
 * author: www.cnblogs.com/luminji
 * date  : 2011/12/28
 */
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Luminji.Core.Data;
using Luminji.Exam.Application;
using Microsoft.Practices.Unity;
using Microsoft.Practices.Unity.Configuration;
using Luminji.Exam.Model;
using Luminji.Core.Enterprise;
using Microsoft.Practices.Unity.InterceptionExtension;
using Luminji.Core.Enterprise.RBAC;

namespace Luminji.ExamWeb.Helpers
{
    public sealed class WebConfiger
    {

        public static void WebInit()
        {
            SqlHelper.ConnectionString = ConfigurationManager.AppSettings["ExamConn"];
            //log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo("log4net.config"));
            ApplicationSession.Title = ConfigurationManager.AppSettings["WebTitle"];
            //UnityInit();
            RoleInit();
        }

        private static void RoleInit()
        {
            //AuthorityHandler.Roles = ApplicationSession.Roles;
        }

        private static void UnityInit()
        {
            ServiceIniter.Container = ContainerFactory.GetContainer(HttpContext.Current.Server.MapPath("~/WebUnity.config"), "unity", "containerService") as UnityContainer;
            ServiceIniter.Container.RegisterType<IControllerFactory, UnityControllerFactory>(new TransientLifetimeManager());
            
            DependencyResolver.SetResolver(new UnityDependencyResolver(ServiceIniter.Container));
        }


    }
}